package cn.com.yusys.yusp.mobile.service;

import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.mobile.repository.mapper.CustomerMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class CustomerService {

    @Resource
    CustomerMapper customerMapper;

    public List<Map<String, Object>> getCustomerLeader(QueryModel queryModel){
        List<Map<String, Object>> list = null;
        list = customerMapper.getCustomerLeader(queryModel);
        return list;
    }
    public List<Map<String, Object>> getExpirationReminder(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getExpirationReminder(queryModel);
        PageHelper.clearPage();
        return list;
    }

    public List<Map<String, Object>> getCustInfo(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getCustInfo(queryModel);
        PageHelper.clearPage();
        return list;
    }

    public List<Map<String, Object>> getMerchantInfo(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getMerchantInfo(queryModel);
        PageHelper.clearPage();
        return list;
    }

    public List<Map<String, Object>> getLargeAmount(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getLargeAmount(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getCustomerOverdue(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getCustomerOverdue(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getWithdrawalInAdvance(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getWithdrawalInAdvance(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getBirthdayCustomerReminder(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getBirthdayCustomerReminder(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getImportantCustomerReminder(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getImportantCustomerReminder(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getWealthCustomerReminder(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getWealthCustomerReminder(queryModel);
        PageHelper.clearPage();
        return list;
    }
    public List<Map<String, Object>> getRepaymentDueReminder(QueryModel queryModel){
        PageHelper.startPage(queryModel.getPage(), queryModel.getSize());
        List<Map<String, Object>> list = null;
        list = customerMapper.getRepaymentDueReminder(queryModel);
        PageHelper.clearPage();
        return list;
    }

    public Map<String, Object> getCustomerInfo(Map  map){
        return customerMapper.getCustomerInfo(map);
    }
    @Transactional
    public Integer addCustomerInfo(Map  map){
        customerMapper.addCustomerInfo(map);
        return this.addCustomerActivityInfo(map);
    }

    @Transactional
    public Integer addCustomerActivityInfo(Map  map){
        if (customerMapper.selectCustomerActivityInfoByCtfNo(map)>0){
            return 0;
        }
        return customerMapper.addCustomerActivityInfo(map);
    }

    @Transactional
    public Integer updateCustomerBasicInformationEditing(Map  map) {
        return  customerMapper.updateCustomerBasicInformationEditing(map);
    }

    @Transactional
    public Integer insertRecordAddInterview(Map  map) {
        return  customerMapper.insertRecordAddInterview(map);
    }

    @Transactional
    public Integer updateCustomerContactInformationEditing(Map map) {
        return  customerMapper.updateCustomerContactInformationEditing(map);
    }

}
